﻿/**
*FrameLayout
*auth:lww
*version:1.0
*date:2014-10-11
*/
function FrameLayout(context, index) {
    this.id = "";
    this.name = "FrameLayout";
    this.version = "1.0.0";
    this.mContext = context;
    this.mLayoutParams = null;
    this.mView = null;
    this.zIndex = index;
}
FrameLayout.prototype.invalidate = function () {
    if (this.mView == null) {
        this.mView = $c("div", this.getId());
        this.mView.style.backgroundColor = "transparent";
        this.mView.style.position = "absolute";
        this.mView.style.zIndex = this.zIndex;
    } else {
        this.mView.style.zIndex = this.zIndex;
    }
    if (this.mLayoutParams != null) {
        this.mView.style.left = this.mLayoutParams.getMarginLeft();
        this.mView.style.top = this.mLayoutParams.getMarginTop();
        this.mView.style.right = this.mLayoutParams.getMarginRight();
        this.mView.style.bottom = this.mLayoutParams.getMarginBottom();

        this.mView.style.paddingLeft = this.mLayoutParams.getPaddingLeft();
        this.mView.style.paddingTop = this.mLayoutParams.getPaddingTop();
        this.mView.style.paddingRight = this.mLayoutParams.getPaddingRight();
        this.mView.style.paddingBottom = this.mLayoutParams.getPaddingBottom();

        this.mView.style.width = this.mLayoutParams.getWidth();
        this.mView.style.height = this.mLayoutParams.getHeight();
    }
    return this.mView;
};
FrameLayout.prototype.view = function () {
    if (this.mView != null)
        return this.mView;
    return this.invalidate();
};
FrameLayout.prototype.getId = function () {
    if (this.id == null || this.id == "") {
        this.id = id();
    }
    return this.id;
};
FrameLayout.prototype.setId = function (ids) {
    this.id = ids;
};
FrameLayout.prototype.setIndex = function (index) {
    this.zIndex = index;
    this.invalidate();
};
FrameLayout.prototype.setLayoutParams = function (pars) {
    if (pars != null) {
        this.mLayoutParams = pars;
        this.invalidate();
    }
};
FrameLayout.prototype.getLayoutParams = function () {
    return this.mLayoutParams;
};
FrameLayout.prototype.setBackground = function (drawable) {
    if (this.mView != null
        && drawable != null
        && typeof (drawable) === "object") {
        if (drawable.getBackgroundColor() != null) {
            this.mView.style.backgroundColor = drawable.getBackgroundColor();
        }
        else if (drawable.getBackgroundImageSrc() != null) {
            this.mView.style.backgroundImage = drawable.getBackgroundImageSrc();
            this.mView.style.backgroundRepeat = drawable.getRepeat();
        }
        if (drawable.getBound() != null) {
            this.mView.style.border = drawable.getBound();
        }
    }
};
FrameLayout.prototype.setClassName = function (name, flag) {
    if (this.mView != null
        && name != null
        && typeof (name) != "undefined") {
        addCss(this.mView, name);
    }
};
FrameLayout.prototype.setGrative = function (grative) {
    if (this.mView != null) {
        this.mView.style.textAlign = grative;
    }
};
FrameLayout.prototype.setInnerHTML = function (html) {
    if (this.mView != null) {
        this.mView.innerHTML = html;
    }
};
FrameLayout.prototype.addChildView = function (child) {
    if (this.mView != null && child != null) {
        this.mView.appendChild(child);
    }
};
FrameLayout.prototype.getChildViewList = function () {
    if (this.mView != null) {
        return this.mView.childNodes;
    }
};
FrameLayout.prototype.removeAllView = function () {
    if (this.mView != null) {
        this.setInnerHTML("");
    }
};
FrameLayout.prototype.setView = function (child) {
    this.removeAllView();
    this.addChildView(child);
};

markscript("FrameLayout");
//end FrameLayout.js